home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / a / a_funk / geograph.tos / GEOGRAPH / SUNCLOCK / GEM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-06  |  4.0 KB  |  118 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <tos.h>
  5. #include <vdi.h>
  6. #include <aes.h>
  7.  
  8. #include "gem.h"
  9.  
  10. /*---- General GEM-variables ----*/
  11. int handle,
  12.     work_out[57],
  13.     work_in[12],
  14.     pxyarray[10],
  15.     txt_attrib[10];
  16.  
  17. char errorsound[100] = {
  18.                   0  ,  0,                          /* Voice A frequention */
  19.                   1  ,  5,
  20.                   2  ,  0,                          /* Voice B frequention */
  21.                   3  ,  0,
  22.                   4  ,  0,                          /* Voice C frequention */
  23.                   5  ,  0,
  24.                   6  ,  50,                           /* Noise frequention */
  25.                   7  ,  0xf6,                                  /* Switches */
  26.                   8  ,  31,                                    /* Volume A */
  27.                   9  ,  0,                                     /* Volume B */
  28.                   10 ,  0,                                     /* Volume C */
  29.                   11 ,  8,                         /* Period of the master */
  30.                   12 ,  3,
  31.                   13 ,  8,                                         /* Wave */
  32.                   0x80, 0,
  33.                   0x81, 0, 0x08, 248,
  34.                   7  ,  0xff,
  35.                   8  ,  0,
  36.                   255,  0
  37. };
  38.  
  39. static bool GemRscLoaded = FALSE;
  40.  
  41. /*-------------------------------------------------------------------------*/
  42. /* GemInit:                                                                */
  43. /* Opens an gem-application.                                               */
  44. /* Load .RSC-file, not when rscfile = NULL.                                */
  45. /*-------------------------------------------------------------------------*/
  46. void GemInit( res, rscfile )
  47. eGetRez res;
  48. char *rscfile;
  49. {
  50.     register int i;
  51.     char str[50];
  52.  
  53.     appl_init();
  54.     for(i=0 ; i<10 ; work_in[i++] = 1);
  55.     work_in[10] = 2;
  56.     v_opnvwk(work_in, &handle, work_out);
  57.     vqt_attributes(handle, txt_attrib);              /* get text attributes */
  58.     v_show_c(handle, 0);
  59.  
  60.     if (!(Getrez() & res)) {
  61.        GemSound();
  62.        strcpy(str, "Wrong resolution:|(");
  63.        if (res & cLowRez) strcat(str, " Low");
  64.        if (res & cMedRez) strcat(str, " Med");
  65.        if (res & cHighRez) strcat(str, " High");
  66.        strcat(str, " )");
  67.        GemAbort(str); 
  68.     }
  69.  
  70.     if (rscfile) {
  71.         GemRscLoaded = TRUE;
  72.         if (!rsrc_load(rscfile))
  73.             GemAbort("Loading .RSC failed!");
  74.     }
  75. }
  76.  
  77. /*-------------------------------------------------------------------------*/
  78. /* GemExit:                                                                */
  79. /* Closes an gem-application.                                              */
  80. /*-------------------------------------------------------------------------*/
  81. void GemExit()
  82. {
  83.     if (GemRscLoaded)
  84.         if (!rsrc_free())
  85.             GemAbort("Freeing .RSC failed!");
  86.     v_clsvwk(handle);
  87.     printf("\033q\033E");
  88.     appl_exit();
  89. }
  90.  
  91. /*-------------------------------------------------------------------------*/
  92. /* GemAbort:                                                               */
  93. /* Aborts the program and returns to the desktop.                          */
  94. /* Usefull on error-conditions.                                            */
  95. /*-------------------------------------------------------------------------*/
  96. void GemAbort(str)
  97. char *str;
  98. {
  99.     char *abortstr;
  100.  
  101.     abortstr = (char*)malloc( strlen(str) + 20 ); 
  102.     sprintf(abortstr, "[3][%s][DESKTOP]", str);
  103.     form_alert(1, abortstr);
  104.     free(abortstr);
  105.     appl_exit();
  106.     Pterm0();
  107. }
  108.  
  109. /*-------------------------------------------------------------------------*/
  110. /* GemSound:                                                               */
  111. /* If an error occurs this sound can be used to get attention of the user. */
  112. /*-------------------------------------------------------------------------*/
  113. void GemSound()
  114. {
  115.     Dosound(errorsound);
  116. }
  117.  
  118.